﻿using System.Collections.Generic;
using System.Linq;
using EntServ.DataModel;
using EntServ.ServiceContracts;

namespace EntServ.Services
{
    public class UserService : IUserService
    {
        #region IUserService Members

        /// <summary>
        /// Gets the name of the users by application.
        /// </summary>
        /// <param name="applicationName">Name of the application.</param>
        /// <returns></returns>
        public List<EntServ.DataContracts.User> GetUsersByApplicationName(string applicationName)
        {
            List<EntServ.DataContracts.User> UserList = new List<EntServ.DataContracts.User>();

            using (ESDBEntities esdb = new ESDBEntities())
            {
                esdb.User_GetUsersByApplicationName(applicationName).ToList()
                    .ForEach(u => UserList.Add(new EntServ.DataContracts.User { UserName = u.UserName }));

                return UserList;
            }
        }

        #endregion
    }
}
